package com.rongc.client.freight.business.waybill.view.adapter;

import android.content.Context;

import com.rongc.client.core.utils.StringUtils;
import com.rongc.client.freight.R;
import com.rongc.client.freight.UniApplication;
import com.rongc.client.freight.base.model.BaseDic;
import com.rongc.client.freight.base.view.adapter.RecyclerBaseAdapter;
import com.rongc.client.freight.business.carrier.model.ConveyanceDic;
import com.rongc.client.freight.business.supply.model.SupplyDic;
import com.rongc.client.freight.business.waybill.model.WayBillBean;

import java.util.List;

/**
 * Created by ccqx on 2017/6/28.
 */

public class RecyclerWaybillListAdapter extends RecyclerBaseAdapter<WayBillBean> {

    public RecyclerWaybillListAdapter(Context mContext, List<WayBillBean> mDatas) {
        super(mContext, mDatas);
    }

    @Override
    protected void onBind(final BaseRecyclerViewHolder holder, int position, WayBillBean data) {
        holder.setText(R.id.tv_departure,data.getStart_ssq());
        holder.setText(R.id.tv_destination,data.getEnd_ssq());
        holder.setText(R.id.tv_date,data.getLoadtime());
        holder.setText(R.id.tv_car,StringUtils.getNewModel(mContext,data.getCarlength(),data.getWeights(),data.getDulk(),data.getCarmodels()));
        // TODO 运单状态
        switch (UniApplication.getInstance().getType()) {
            case BaseDic.IdentityType.DRIVING_TYPE:
                holder.setText(R.id.tv_status, ConveyanceDic.getStatusStr(StringUtils.parseInt(data.getWaystate())));
                holder.setText(R.id.tv_identity, R.string.main_title_carrier);
                break;
            case BaseDic.IdentityType.OWNER_TYPE:
                holder.setText(R.id.tv_status, SupplyDic.getStatusStr(StringUtils.parseInt(data.getWaystate())));
                holder.setText(R.id.tv_identity, R.string.main_title_shipper);
                break;
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.recycler_main_list_item;
    }
}
